package routers

import (
	"github.com/gin-contrib/cors"
	"github.com/gin-gonic/gin"
	"yklx/handlers"
)

func Init() *gin.Engine {

	r := gin.Default()
	r.Use(cors.Default())
	r.Static("static", "./static")
	r.POST("/user/login", handlers.UserLogin)         //用户登录
	r.POST("/user/roleAddNode", handlers.RoleAddNode) //角色分配权限
	r.GET("/user/userRole", handlers.UserRole)        //用户角色信息
	r.GET("/user/roleNode", handlers.RoleNode)        //角色权限信息
	r.POST("/car/add", handlers.Add)                  //汽车添加
	r.POST("/car/orderAdd", handlers.OrderAdd)        //送货订单添加
	r.GET("/car/orderList", handlers.OrderList)       //订单列表
	r.GET("/car/orderDetail", handlers.OrderDetail)   //订单详情

	return r

	//// 1.创建路由
	//r := gin.Default()
	//// 2.绑定路由规则，执行的函数
	//// gin.Context，封装了request和response
	//r.GET("/", func(c *gin.Context) {
	//	c.String(http.StatusOK, "hello World!")
	//})
	//// 3.监听端口，默认在8080
	//// Run("里面不指定端口号默认为8080")
	//r.Run(":8000")
}
